package cn.edu.gxu.oas.module.run.dal.mysql.record;

import java.util.*;

import cn.edu.gxu.oas.framework.common.pojo.PageResult;
import cn.edu.gxu.oas.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.edu.gxu.oas.framework.mybatis.core.mapper.BaseMapperX;
import cn.edu.gxu.oas.module.run.dal.dataobject.record.RecordDO;
import org.apache.ibatis.annotations.Mapper;
import cn.edu.gxu.oas.module.run.controller.admin.record.vo.*;

/**
 * 跑步记录 Mapper
 *
 * @author 源码
 */
@Mapper
public interface RecordMapper extends BaseMapperX<RecordDO> {

    default PageResult<RecordDO> selectPage(RecordPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<RecordDO>()
                .eqIfPresent(RecordDO::getStudentId, reqVO.getStudentId())
                .betweenIfPresent(RecordDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(RecordDO::getEndTime, reqVO.getEndTime())
                .eqIfPresent(RecordDO::getDuration, reqVO.getDuration())
                .eqIfPresent(RecordDO::getDistance, reqVO.getDistance())
                .eqIfPresent(RecordDO::getPace, reqVO.getPace())
                .eqIfPresent(RecordDO::getCalorie, reqVO.getCalorie())
                .eqIfPresent(RecordDO::getPoints, reqVO.getPoints())
                .eqIfPresent(RecordDO::getRouteData, reqVO.getRouteData())
                .eqIfPresent(RecordDO::getStatus, reqVO.getStatus())
                .eqIfPresent(RecordDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(RecordDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(RecordDO::getId));
    }

}